<%@ page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8"%>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core"%>
<%@ taglib prefix="shiro" uri="http://shiro.apache.org/tags" %>
<!DOCTYPE html>
<html>
<head>
<link rel="shortcut icon" href="${_resources}/logo.png"/>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>软件资产管理平台</title>

<%@ include file="/WEB-INF/jsp/common/inc.jsp" %>
<script type="text/javascript">
$(function (){
	var menuParents = '${menuParents}';
	var menuJson = eval('(' + menuParents + ')');
	var li = "<a class='navleft' onclick='showLeft()' href='javascript:;'><</a>";
	for(var i=0;i<menuJson.length;i++){
		li += "<li name='menu' class=\""+menuJson[i].classType+"\"><a id=\""+menuJson[i].menuId+"\" href=\"javascript:;\" onclick=\"skip('"+menuJson[i].menuUrl+"','"+menuJson[i].menuId+"');changeCss(this,'"+menuJson[i].classType+"')\" >"+menuJson[i].menuName+"</a></li>";
	}
	li += "<a class='navright' onclick='showRight()' href='javascript:;'>></a>";
	//$("#ul").children("li").remove();
	//$("#ul").append(li);
	$("#ul").html(li);
	
	//默认点击第一个
	$("#ul>li:visible:nth-child(2) >a").click();
	
	//<a id="af1d3b3615744601a71c510b75d0d08f" href="javascript:;" onclick="
	
	//skip('/workbench/showWorkbench','af1d3b3615744601a71c510b75d0d08f');
	//changeCss($("#ul>li:visible:nth-child(2) >a"),'icon-20');
	
	//">我的工作台</a>
	
	//提示修改密码
	if("true" == "${updateMessage}"){
		layer.confirm('密码即将失效，请尽快更换平台登录密码。', {
		  btn: ['确定','取消'] //按钮
		}, function(index){
			layer.close(index);
			editPwdFun();
		});
	}
	
	/* 退出 */
	$("#login_out_close_windows").click(function(){
		$.ajax({
	        type: "post",
	        dataType: "html",
	        url: '${_baseUrl}/logout/closewindows',
	        data: {},
	        success: function (data) {
	        	//关闭浏览器支持火狐
	         	var userAgent = navigator.userAgent;
				if (userAgent.indexOf("Firefox") != -1 || userAgent.indexOf("Chrome") !=-1) {
				   window.location.href="about:blank";
				} else {
				   window.opener = null;
				   window.open("", "_self");
				   window.close();
				};
	        }
	    });
	});
});


function changeCss(evl,icon){
	var child = evl.parentNode.parentNode.childNodes;
	for(var i=0;i<child.length;i++){
		if(child[i].nodeName=="LI"){
			var classType = $(child[i]).attr("class");
			if(typeof(classType) != "undefined"){
				if(classType.indexOf("navicon_on") > 0){
					child[i].removeAttribute("class");
					classType = classType.replace("navicon_on","");
					child[i].setAttribute("class",classType+"");
				}
			}
			
		}
	}
	evl.parentNode.setAttribute("class",icon+" navicon_on");
}

/* 跳转 */
function skip(url,menuId){
	if(url=="/workbench/showWorkbench"){
		$(".ban_yue").css("display","none");
		$(".header").removeClass("header2");
		$(".header").addClass("header1");
		}else{
			$(".ban_yue").css("display","inline-block");
			$(".header").removeClass("header1");
			$(".header").addClass("header2");
		}
	
	
	
	
	
	var div = document.getElementById("contIframe");
	if(url.indexOf("?") > 0){
		div.src ="${_baseUrl}"+url+"&menuId="+menuId;
	}else{
		div.src ="${_baseUrl}"+url+"?menuId="+menuId;
		
	}
}

function editPwdFun(){
	layer.open({
        type: 2 //Page层类型
        ,area: ['500px', '400px']
        ,title: '修改密码'
        ,shade: 0.3 //遮罩透明度
        ,maxmin: true //允许全屏最小化
        ,anim: -1 //0-6的动画形式，-1不开启
        ,content: '${_baseUrl}/userController/editPwdPage'
	});
}


function closeAndSkip(moduleName,url,id){
	//将消息修改成已读
	$.ajax({
        type: "post",
        dataType: "json",
        url: '${_baseUrl}/index/updateMessageStatus',
        data: {messageId:id},
        success: function (data) {
        	if("1" == data.code){
        		//关闭弹出框
        		closeWin();
        		//跳转
        		skipModule(moduleName,url);
        	}else{
        		layer.msg(data.message);
        	}
        },
        error:function(json){
			layer.msg("系统错误,请联系管理员");
		}
    });
}

//跳转  跳转到上下结构
function skipModule(moduleName,url){
	//修改css样式
	$("#ul").children("li").each(function (){
		$(this).removeAttr("class");
		var a = $(this).children("a");
		if(a.html() == moduleName){
			$(this).attr("class","navicon_on");
			if("" == url){
				a.click();
			}
		}
	});
	//跳转路径
	if("" != url){
		var div = document.getElementById("contIframe");
		div.src = url;
	}
}
	
/* 待办事项 */
function showHandMessage(){
 	$("#editPwdIframe").empty();	
	$("#editPwdDiv").dialog({
		title:'待办事项',
		autoOpen: true,
		modal: true,	
		height: 500,
		width: 900
	});	
	$("#editPwdIframe").attr("width","100%");
	$("#editPwdIframe").attr("height","95%");
	$("#editPwdIframe").attr("src","${_baseUrl}/index/showHandMessage?random="+Math.random());
}

/* 待阅事项 */
function showReadMessage(){
	$("#editPwdIframe").empty();	
	$("#editPwdDiv").dialog({
		title:'待阅事项',
		autoOpen: true,
		modal: true,	
		height: 500,
		width: 900
		
	});	
	$("#editPwdIframe").attr("width","100%");
	$("#editPwdIframe").attr("height","95%");
	
	$("#editPwdIframe").attr("src","${_baseUrl}/index/showReadMessage?random="+Math.random());
}

function saveReplace(){
	try{
	$(window.parent.document).contents().find("#indexIframe")[0].contentWindow.saveReplace();
	}
	catch(err){
		return;
	}		
}
function showBeforeSection(){
	try{
	$(window.parent.document).contents().find("#indexIframe")[0].contentWindow.showBeforeSection();
	}
	catch(err){
		return;
	}		
}
/* 关闭弹出框 */
function closeWin(){
	layer.closeAll();
}

</script>
<style type="text/css">


</style>
</head>
<body>
<div class='wrap'>
    <div class='header'>
    	<div style="height:50px;position: relative;">
    		<div style="position: absolute;top: 15px;left:30px;color:#fff">软件资产管理平台</div>
    		<div class="ban_yue">
    			<div class="nav_ban">办</div>
    			<div class="nav_yue">阅</div>
    		</div>
    		<div class='install fr clearfix'>
	            <div id='define' class='define' href="javascript:;">
	            	admin
	                <div id='tag-define' class='tag'>
	                    <div class='d-box'></div>
	                    <div class='arrow'>
	                        <em></em><span></span>
	                    </div>
	                    <ul class="install_func">
	                        <li id='t-d-cancel'><a href="${_baseUrl}/logout">注销</a></li>
	                        <li><a href="javascript:;" onClick="editPwdFun();">修改密码</a></li>
	                        <li><a id="login_out_close_windows" href="javascript:;">退出</a></li>
	                    </ul>
	                </div>
	            </div>
        	</div>
    	</div>

	        <ul class="nav clearfix" id="ul">
	            <!--功能模块 -->
	        </ul>
    </div>
    <div id='iframeCont' class='iframeCont'>
        <iframe id="contIframe" name='contIframe' class='contIframe' width='100%' height='100%' frameborder="none" scrolling="auto" ></iframe>
    </div>
</div>
</body>
<script type='text/javascript'>
var initWidth = document.documentElement.clientWidth;
var liW = $(".nav li").width();
/* var logoW = $('.logo').outerWidth(true); */
var showMax = Math.floor((initWidth-500)/liW);  // 能够显示的最大li
var pointer = showMax - 1;
var length = 15;
	 window.onload = function(){
		 initWidth = document.documentElement.clientWidth;
		 liW = $(".nav li").width();
		 showMax = Math.floor((initWidth-500)/liW);  // 能够显示的最大li
		 pointer = showMax - 1;
		 length = 15;
		 
		 initHeight();
			navStatus();
			setDefine();
			crossFold();
			setAuto();
		 navAdjust();
		  }
	// =============================================
	window.onresize = function(){
		setTimeout('initHeight();setAuto();navAdjust()',100);
		initWidth = document.documentElement.clientWidth;
		liW = $(".nav li").width();
		showMax = Math.floor((initWidth-500)/liW); // 能够显示的最大li
		pointer = showMax - 1;
		length = 15;
	};
		// 导航栏显示影藏
		function navAdjust(){	
	        var winW = window.screen.width,
	                ulW = $(".nav").width(),
	                oli = $("li[name='menu']"),
	                oMR = $(".navright"),
	                oML = $(".navleft"),
	                liW = 0;
	        //alert("ulw="+ulW);
	       
	        for(var i = 0; i<oli.length; i++){
	            liW += oli.eq(i).width();
	            if(ulW<liW){
	            	//alert(liW);
	                oli.eq(i).css('display','none');
	            }else{
	                oli.eq(i).css('display','block');
	            }           
	        }	        
	    }
	//一级菜单：查看左边隐藏菜单
	function showLeft(){
		if(pointer-showMax >= 0){
			$("li[name='menu']").eq(pointer).css('display','none');
			$("li[name='menu']").eq(pointer-showMax).css('display','block');
			pointer = pointer - 1;
		}
	}
	//一级菜单：查看右边隐藏菜单
	function showRight(){
		if(pointer-length <= 0){
		pointer = pointer +1;
		$("li[name='menu']").eq(pointer).css('display','block');
		$("li[name='menu']").eq(pointer-showMax).css('display','none');	
		}
	}
// =============================================

	function initHeight(){
		var topH = $('.header').height(),
		    initheight = document.documentElement.clientHeight - topH-5,
		    oCont = $('#iframeCont') ;
		oCont.height(initheight);
	};
	// 导航栏样式定义
	function navStatus(){
		var oNav = $(".nav li[name='menu']"),
		    oIfr = $('.contIframe');
		//document.getElementById('icon1_a').click();
		oNav.each(function(){
			$(this).click(function(){
			    $(this).removeClass("navicon_on").addClass("navicon_on");
			    oNav.not($(this)).removeClass('navicon_on');
			});
		});
	};
	// 定义下拉菜单
	function setDefine(){
		var oIn = $('#define'),
		    oTag = $('#tag-define');
		oIn.mouseover(function(){
			oTag.css('display','block');
			$('#t-d-cancel').trigger('click');
		}).mouseleave(function(){
			oTag.css('display','none');
		});
	};

	// 横向折叠
	function crossFold(){
		var oCont = $('#cont2'),
		    oHeader = $('.header'),
		    oIframe = $('.iframeCont'),
		    oHeaderH = oHeader.height(),
		    temp=0;
		
		oCont.bind('click',function(){
			if(temp == 0){
			    oHeader.css({'overflow':'hidden'});
			    $(this).addClass('open2');
			    oIframe.animate({'height':oIframe.height()+oHeaderH});
			    oHeader.animate({'height':'0'});
			    temp = 1;
			}else if(temp == 1){
			    oHeader.css({'overflow':'visible'});
			    $(this).removeClass().addClass('close2');
			    oHeader.animate({'height':'84px'});
			    oIframe.animate({'height':oIframe.height()-oHeaderH});
			    temp = 0;
			}
		});
	}
	// 设置自适应
	function setAuto(){
		var initwidth = document.documentElement.clientWidth;
		
		if(initwidth >= '1680'){
			$('html').css('font-size','100%');
		}else if(initwidth >= '1025'){
			$('html').css('font-size','90%');
		}else {
			$('html').css('font-size','80%');
		}
	}
	
	
	$(function(){
        $("#todo").click(function() {
        	layerIndex = layer.open({
                type: 2 //Page层类型
                ,area: ['700px', '600px']
                ,title: '我的工作台--待办事项'
                ,shade: 0.6 //遮罩透明度
                ,maxmin: true //允许全屏最小化
                ,anim: false //0-6的动画形式，-1不开启
                ,content: '${_baseUrl}/workbench/showNeedHandleEvent'
            });
        	/* layer.full(layerIndex); */
        });
    })
    $(function(){
        $("#pending_items").click(function() {
        	layerIndex = layer.open({
                type: 2 //Page层类型
                ,area: ['700px', '600px']
                ,title: '我的工作台--待阅事项'
                ,shade: 0.6 //遮罩透明度
                ,maxmin: true //允许全屏最小化
                ,anim: false //0-6的动画形式，-1不开启
                ,content: '${_baseUrl}/showNeedReadEvent'
            });
        	/* layer.full(layerIndex); */
        });
    }) 

</script>
</html>